<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage" style="overflow: hidden;">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>新建文件夹</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">位置</label>
                        <div class="layui-input-block">
                            <input type="text" id="muid_name" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">排序号</label>
                        <div class="layui-input-block">
                            <input type="text" name="sort" id="sort" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
<!--                    <div class="layui-col-md12">-->
<!--                        <label class="layui-form-label">文件查看授权</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <input type="text" readonly name="auth" class="layui-input auth" onclick="openPage('../public/choose_dealcom.php?choose_type=checkbox&page=jia&dom=auth','100%','100%')">-->
<!--                            <div class="choose_div" id="auth" key="1"></div>-->
<!--                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?choose_type=checkbox&page=jia&dom=auth','100%','100%')"><i class="layui-icon layui-icon-search"></i></span>-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="layui-col-md12">
                        <label class="layui-form-label">文件查看授权</label>
                        <div class="layui-input-block">
                            <div id="auth"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12" >
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</form>
<script>
    var param_muid = getQueryVariable('muid') || 0;
    var param_enginid = getQueryVariable('enginid') || 0;

    $("#commentForm").validate({
        rules: {
            name: {required: true},
        },
        messages:{
            name: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();
        facade.ajax({type: 'get', url: ask_engin_mu_add, data:{muid: param_muid, enginid:param_enginid}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data;
                $("#muid_name").val(data.muid_name);


                xmselect_duo('auth', res.data.authArr, '');


                render_from();
            }
        });




        form.on('submit(add)', function(data){
            var validRes = $("#commentForm").valid();
            if(!validRes){return false;}

            data.field.muid = param_muid;
            data.field.enginid = param_enginid;
            facade.ajax({url: ask_engin_mu_add, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    facade.success("提交成功!");
                    setTimeout(() => {
                        try {
                            parent.get_mu_info(param_muid);
                            parent.get_jia_info(param_muid);
                        }catch (e) {

                        }
                        layer_close_opt();
                    }, 1500);
                }
            });

            return false;
        });

    });

</script>
</body>
</html>
